package work2;

public class Test {
    public static void main(String[] args) {
        Person p = new Person();
        p.sleep();

        Student s = new Student("张三",23);
        s.sleep();
    }
}


class Person{
    private String name;
    private  int age;

    public void sleep(){
        System.out.println("休息是人的本能");
    }

    public Person() {
    }

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

class Student extends Person{
    @Override
    public void sleep() {
        System.out.println("年龄为"+getAge()+"的"+getName()+"学生正在教室睡午觉");
    }

    public Student() {
    }

    public Student(String name, int age) {
        super(name, age);
    }
}